-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update evm_consumer functions implemented #2
base: base/consumer-chain-support
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clientcontroller/evm_consumer.go
Outdated
Hash string | ||
} | ||
|
||
var Batch []rpc.BatchElem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here Batch
should be batch
clientcontroller/evm_consumer.go
Outdated
|
||
var Batch []rpc.BatchElem | ||
|
||
InitBatch(Batch, startnumber, count, "ascent") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InitBatch
-> initBatch
if you check other function in the file, first-letter-capitalization is only for interface function.
clientcontroller/evm_consumer.go
Outdated
return nil, fmt.Errorf("error:%s", err) | ||
} | ||
|
||
ibatch := &types.BlockInfo{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does ibatch
mean? it's a block not a batch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to block
clientcontroller/evm_consumer.go
Outdated
|
||
for _, batch := range batchArray { | ||
nb := batch.Result.(*Block) | ||
num, err := strconv.ParseUint(strings.TrimPrefix(nb.Number, "0x"), 16, 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks very wrong. query a block should be very simply and standard operation
the entire implementation of this function should be concise
discussed w @XiangEnze and @lesterli offline. a few things:
references: |
clientcontroller/evm_consumer.go
Outdated
|
||
var blocks []*types.BlockInfo | ||
|
||
/*will be implemented in next PR, wait for "refactor: QueryLatestFinalizedBlocks(count uint64) -> QueryLatestFinalizedBlock() #347" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok it's already merged now. see the msg in TG group and update accordingly
you also need to sync changes from upstream and change base branch
clientcontroller/evm_consumer.go
Outdated
} | ||
|
||
func (ec *EVMConsumerController) queryLatestBlocks(startKey []byte, count uint64, status finalitytypes.QueriedBlockStatus, reverse bool) ([]*types.BlockInfo, error) { | ||
var blocks []*types.BlockInfo | ||
|
||
// Can be deleted for never using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's easy to do, you can just remove it here
Makefile
Outdated
@@ -56,6 +56,7 @@ build-docker: | |||
|
|||
.PHONY: test | |||
test: | |||
make mock-gen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted
finality-provider/config/evm.go
Outdated
RPCL1Addr string `long:"rpc-address" description:"address of the L2 RPC server to connect to"` | ||
RPCL2Addr string `long:"rpc-address" description:"address of the L1 RPC server to connect to"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"RPCL1Addr - address of the L2 RPC"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
finality-provider/config/evm.go
Outdated
RPCAddr string `long:"rpc-address" description:"address of the rpc server to connect to"` | ||
RPCL1Addr string `long:"rpc-address" description:"address of the L2 RPC server to connect to"` | ||
RPCL2Addr string `long:"rpc-address" description:"address of the L1 RPC server to connect to"` | ||
L2OutputOracleContractAddress string `long:"sol-address" description:"address of the L2output smart contract"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L2output -> L2OutputOracle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
finality-provider/config/evm.go
Outdated
RPCL1Addr string `long:"rpc-address" description:"address of the L2 RPC server to connect to"` | ||
RPCL2Addr string `long:"rpc-address" description:"address of the L1 RPC server to connect to"` | ||
L2OutputOracleContractAddress string `long:"sol-address" description:"address of the L2output smart contract"` | ||
BitcoinStackingContractAddress string `long:"sol-address" description:"address of the Bitcoinstaking smart contract"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this is also called long:"sol-address"
? sounds wrong
what does "long" mean here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
Summary
Updated EVMConfig for necessary addresses for evm_consumer, add some functions to avoid duplicates or large functions.
Import
op-bindings
:so we can interact with the L1 contract like the L2OutputOracle
Replaced
evmclient
withl1Client
andl2Client
, so we can reuse both to get information L1 and L2.Using
ethclient
instead ofrpc.client
made functions much more lightweight.Deleted useless functions.
Note that loading full blocks by
BlockByNumber
requires two requests, so useHeaderByNumber
if we don't need all transactions or uncle headers.Updated
sdk "github.com/cosmos/cosmos-sdk/types"
not used any more, already deletedqueryLatestBlocks()
is not used any more, already deletedQueryLatestFinalizedBlocks()
Next Steps:
QueryActivatedHeight
Test Plan